package com.lanxin.zc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanxin.bx.vo.AllinformalVo;
import com.lanxin.zc.entity.ZcAssetpurchaseapply;
import com.lanxin.zc.mapper.ZcAssetpurchaseapplyMapper;
import com.lanxin.zc.service.IZcAssetpurchaseapplyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lanxin.zc.vo.AllzcassetpurchaseapplyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2025-07-16
 */
@Service
public class ZcAssetpurchaseapplyServiceImpl extends ServiceImpl<ZcAssetpurchaseapplyMapper, ZcAssetpurchaseapply> implements IZcAssetpurchaseapplyService {
    @Autowired
    private ZcAssetpurchaseapplyMapper assetpurchaseapplyMapper;

    //根据部门获取待审批申请单
    @Override
    public List<ZcAssetpurchaseapply> getAssetpurchaseappliesByDept(Integer deptId) {
        QueryWrapper<ZcAssetpurchaseapply> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deptid", deptId);
        queryWrapper.eq("status", "O");
        return assetpurchaseapplyMapper.selectList(queryWrapper);
    }

    //根据部门获取所有资产购买申请单
    @Override
    public List<ZcAssetpurchaseapply> listAssetpurchaseappliesByDept(Integer deptId) {
        QueryWrapper<ZcAssetpurchaseapply> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("deptid", deptId);
        return assetpurchaseapplyMapper.selectList(queryWrapper);
    }

    //修改资产购买的申请状态
    @Override
    public int updateAssetPurchaseStatus(Integer oid, String status) {
        Map<String, Object> map = new HashMap<>();
        map.put("oid", oid);
        map.put("status", status);
        return assetpurchaseapplyMapper.updateAssetPurchaseStatus(map);
    }

    @Override
    public Page<AllzcassetpurchaseapplyVo> selectzcassetpurchList(Integer page, Integer pageSize, String docNo, String empName, String submitDate, String status) {
        PageHelper.startPage(page, pageSize);

        List<AllzcassetpurchaseapplyVo> allzcassetpurchaseapplyVos=assetpurchaseapplyMapper.selectzcassetpurchList(docNo, empName, submitDate, status);
        return (Page<AllzcassetpurchaseapplyVo>) allzcassetpurchaseapplyVos;
    }

    @Override
    public Page<AllzcassetpurchaseapplyVo> selectmyzcassetpurchList(Integer page, Integer pageSize, String docNo, String submitDate, String status, Integer proposer) {
        PageHelper.startPage(page, pageSize);

        List<AllzcassetpurchaseapplyVo> myallzcassetpurchaseapplyVos=assetpurchaseapplyMapper.selectmyzcassetpurchList(docNo, submitDate, status, proposer);
        return (Page<AllzcassetpurchaseapplyVo>) myallzcassetpurchaseapplyVos;
    }
}
